//
//  CarViewModel.m
//  DingDongXiChe
//
//  Created by wtjr on 2018/1/11.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "CarViewModel.h"

@implementation CarViewModel

- (NSMutableArray *)cars {
    if (!_cars) {
        _cars = [NSMutableArray new];
        NSBundle *bundle = [NSBundle mainBundle];
        NSString *path = [bundle pathForResource:@"AllCars" ofType:@"plist"];
        NSArray  *cards = [NSArray arrayWithContentsOfFile:path];
        
        for (NSDictionary *dicationary in cards) {
            NSArray *temp = dicationary[@"cars"];
            for (NSDictionary *dic in temp) {
                CarBrandModel *model = [[CarBrandModel alloc] initWithDic:dic];
                [_cars addObject:model];
            }
        }
    }
    return _cars;
}

@end
